package cn.agiledata.bank.linkbank.logic.payment;

import java.math.BigDecimal;

import cn.agiledata.bank.common.util.Constant;

/**
 * 支付系统响应
 * 
 * @author maxianbo
 * 
 */
public class UnsPayResponse {
    /**
     * 支付成功时的返回码
     */
    public static final String RETURN_CODE_SUCCESS = "0000";

    /**
     * 担保交易中买方已支付时的返回码
     */
    public static final String RETURN_CODE_PAID = "0001";

    /**
     * 银行返回失败时的返回码
     */
    public static final String RETURN_CODE_BANK_FAILURE = "1001";

    /**
     * 商户账户编号
     */
    private String accountId;

    /**
     * 商户密钥
     */
    private String accountKey;

    /**
     * 订单号
     */
    private String orderId;

    /**
     * 货币类型
     */
    private String currencyType = Constant.CURRENCY_RMB;

    /**
     * 已支付金额
     */
    private BigDecimal amount;

    /**
     * 订单对应支付系统交易编号
     */
    private String unsTransId;

    /**
     * 返回码
     */
    private String returnCode;

    /**
     * 返回消息
     */
    private String returnMessage;

    /**
     * 商户url
     */
    private String merchantUrl;

    /**
     * 响应模式
     */
    private int responseMode;

    /**
     * 是否内部交易
     */
    private boolean inner;
    
    /**
     * 卡号
     */
    private String cardNo;

    /**
     * 是否需要银行接口确认交易
     */
    private boolean affirmable;

    /**
     * 是否已经经过确认
     */
    private boolean affirmed;
    
    /**
     * 银行编号
     */
    private String bankCode;

    public UnsPayResponse(String accountId, String orderId, BigDecimal amout,
            String merchantUrl, int responseMode) {
        this.accountId = accountId;
        this.accountKey = "";
        this.orderId = orderId;
        this.amount = amout;
        this.merchantUrl = merchantUrl;
        this.responseMode = responseMode;
        this.returnCode = RETURN_CODE_SUCCESS;
        this.returnMessage = "";
        this.affirmable = true; // 默认需要银行接口确认交易
    }

    public String getAccountId() {
        return this.accountId;
    }

    public String getAccountKey() {
        return this.accountKey;
    }

    public BigDecimal getAmount() {
        return this.amount;
    }

    public String getCurrencyType() {
        return this.currencyType;
    }

    public String getUnsTransId() {
        return this.unsTransId;
    }

    public String getMerchantUrl() {
        return this.merchantUrl;
    }

    public String getOrderId() {
        return this.orderId;
    }

    public int getResponseMode() {
        return this.responseMode;
    }

    public String getReturnCode() {
        return this.returnCode;
    }

    public String getReturnMessage() {
        return this.returnMessage;
    }

    public boolean isAffirmable() {
        return this.affirmable;
    }

    public boolean isAffirmed() {
        return this.affirmed;
    }

    /**
     * 
     * @return 是否内部交易
     */
    public boolean isInner() {
        return this.inner;
    }

    /**
     * 
     * @return true if 交易成功，otherwise false
     */
    public boolean isSuccessful() {
        return RETURN_CODE_SUCCESS.equals(this.returnCode) || RETURN_CODE_PAID.equals(this.returnCode);
    }

    /**
     * 
     * @return true if 担保交易已付款，otherwise false
     */
    public boolean isPaid() {
        return RETURN_CODE_PAID.equals(this.returnCode);
    }

    public void setAccountKey(String accountKey) {
        this.accountKey = accountKey;
    }

    public void setInner(boolean inner) {
        this.inner = inner;
    }

    public void setAffirmable(boolean affirmable) {
        this.affirmable = affirmable;
    }

    public void setAffirmed(boolean affirmed) {
        this.affirmed = affirmed;
    }

    public void setCurrencyType(String currencyType) {
        if (currencyType != null)
            this.currencyType = currencyType;
    }

    public void setUnsTransId(String unsTransId) {
        this.unsTransId = unsTransId;
    }

    public void setMerchantUrl(String merchantUrl) {
        this.merchantUrl = merchantUrl;
    }

    public void setReturnCode(String returnCode) {
        this.returnCode = returnCode;
    }

    public void setReturnMessage(String returnMessage) {
        this.returnMessage = returnMessage;
    }

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public String getBankCode() {
		return bankCode;
	}

	public void setBankCode(String bankCode) {
		this.bankCode = bankCode;
	}
}
